<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 对象定义
        let student1 = {};
        let student2 = {
            "name": "huozhe",
            "age": 20
        }
        // 读取
        console.log(student2.name);
        console.log(student2["name"]);
        // 修改
        student2.name = "nobody";
        console.log(student2.name);
        console.log(student2);
        // 添加
        student1.name = "赋值姓名";
        console.log(student1);
        // 删除
        delete student1.name;
        console.log(student1);

        // 函数表达式
        // 写了一个匿名函数，将这个匿名函数用一个变量表示，后续使用这个变量来调用函数
        let add = function() {
            let sum = 0;
            for(let i = 0; i < arguments.length; i++){
                sum += arguments[i];
            }
            return sum;
        }
        console.log(add(10, 20));

        // 使用Object创建对象，使用类似于数组
        let object = new Object();
        // 使用函数创建对象，类似于Java中的用法
        function total(name, age){
            this.name = name;
            this.age = age;
        }
        let totalep = new total("huozhe", 20);
        console.log(totalep.name);
    </script>
</body>
</html>